using System;
using System.Diagnostics;
using System.Configuration;
using Gtk;
using Jandaya.Framework;
using Jandaya.Framework.Application;
using Jandaya.Client.Dialogs;


namespace Jandaya.Client
{
	class App
	{
		private static AppManager _appManager = null;
		private static AuthenticationInfo _authInfo = null;
		private static dlgLogin _loginDialog = null;		
		
		public static void Main (string[] args)
		{
			TextWriterTraceListener consoleoutput = new TextWriterTraceListener(Console.Out);
			Debug.Listeners.Add(consoleoutput);
			
			Application.Init();		
			App.Manager.LoadConfiguration();
			if (App.Manager.Config.ConfigLoaded){
				LoginDialog.Show();
				Application.Run();				
			}
			else{				
				Application.Quit();
			}			
		}
		
		
		public static AuthenticationInfo Authentication{
			get{
				if (_authInfo == null )
					_authInfo = new AuthenticationInfo();
				return _authInfo;
			}
		}
		
					
		public static AppManager Manager{
			get {
				if (_appManager == null)
					_appManager = new AppManager();
				return _appManager;
			}
		}
		
				
		public static dlgLogin LoginDialog{
			get { 
				if (_loginDialog == null)
					_loginDialog = new dlgLogin();
				return _loginDialog; 
			}
			
		}
		
		
	}
}

